package com.java.tutorials.solr;

import com.alibaba.fastjson.JSON;
import org.apache.solr.client.solrj.beans.Field;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by xuzhike on 2016/1/5.
 */
public class UserInfo implements Serializable {
    @Field("id")
    private String id;

    @Field("name_s")
    private String name;

    @Field("age_i")
    private int age;

    @Field("man_b")
    private boolean man;

        @Field(value="phone_s")
    private List<String> phones = new ArrayList<String>();

    @Field(value="addressList_s")
    private List<String> addrList = new ArrayList<String>();

    @Field(value="addressList_o")
    private List<Address> addressList = new ArrayList<Address>();

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public boolean isMan() {
        return man;
    }

    public void setMan(boolean man) {
        this.man = man;
    }

    public List<Address> getAddressList() {
        return addressList;
    }

    public void setAddressList(List<Address> addressList) {
        this.addressList = addressList;
    }

    public List<String> getPhones() {
        return phones;
    }

    public void setPhones(List<String> phones) {
        this.phones = phones;
    }

    public List<String> getAddrList() {

        return addrList;
    }

    public void updateAddrList(){
        for(Address address: this.getAddressList()){
            addrList.add(JSON.toJSONString(address));
        }
    }

    public void setAddrList(List<String> addrList) {
        this.addrList = addrList;
    }

    @Override
    public String toString() {
        return "UserInfo{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", man=" + man +
                ", phones=" + phones +
                ", addrList=" + addrList +
                ", addressList=" + addressList +
                '}';
    }
}
